/**
 * Created by jiangtao on 2017/5/31.
 */

import React , { Component } from 'react';

import connect from './../../../redux/connect';

// import './../../../styles/pc/detail.scss';

class Deatil extends Component {
    constructor(){
        super();
        this.state={
            show:false
        }
    }

    componentDidMount(){
        const { id } = this.props.match.params;
        this.props.homeActions.getDetail(id,()=>{
            this.setState({
                show:true
            })
        });
    }

    isEmpty(obj = {}){
        for(let key in obj) {
            return false
        }
        return true;
    }

    render(){
        const detail = this.props.homeReducer.dataDetail;
        if(this.isEmpty(detail)) return null;
        const { show } = this.state;
        return(
            <div className={`detail-page${show ? ' show' :''}`}>
                <div className="title-box">
                    <div className="title">{detail.title}</div>
                </div>
                <div className="content" dangerouslySetInnerHTML={{__html:detail.content}}></div>
            </div>
        )
    }

}



import homeActions from './../../../redux/action/home';

export default connect({
    reducers:{
        homeReducer:"home"
    },
    actions:{
        homeActions:homeActions
    }
})(Deatil);